package model;

import java.util.List;
import java.util.Random;

/**
 * A class representing shared characteristics of field modifiers.
 * 
 * @author David J. Barnes and Michael Kölling
 * @version 2011.07.31
 */

class FieldModifier implements Actor {

    // The modifiers's field.
    private Field field;
    // The modifier's position in the field.
    private Location location;
    //make random
    private static final Random rand = Randomizer.getRandom();
    
    /**
     * Create a new modifier at location in field.
     * 
     * @param field The field currently occupied.
     * @param location The location within the field.
     */
    public FieldModifier(Field field, Location location)
    {
        this.field = field;
        setLocation(location);
    }
    
	/**
     * Perform the actor’s regular behavior.
     * @param newActors A list for receiving newly created actors.
     */
	public void act(List<Actor> newActors) {
		
	}
	
    /**
     * Return the modifier's location.
     * @return The modifier's location.
     */
    protected Location getLocation()
    {
        return location;
    }
    
    /**
     * Place the modifier at the new location in the given field.
     * @param newLocation The modifier's new location.
     */
    protected void setLocation(Location newLocation)
    {
        if(location != null) {
            field.clear(location);
        }
        location = newLocation;
        field.placeModifier(this, newLocation);
    }
    
    /**
     * Return the modifier's field.
     * @return The modifier's field.
     */
    protected Field getField()
    {
        return field;
    }

    /**
     * Is the actor still active?
     * @return true if still active, false if not.
     */
	public boolean isActive() {
		return true;
	}

}